/**
 * Created by Mission on 16/10/17.
 */
/**
 * @Name：日历控件
 * @Description：手机日历控件
 */

var today;
var month;
var year;
var start_time;
var end_time;
var day;
var turnDay;

/*
 * 初始化时间控件，传入要渲染div的id与日历的点击事件
 */
function initCalendar() {
    (function ($) {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }
    })(jQuery);
    turnDay = $.getUrlParam('turnDay');
    initTime();
    turn_day();//对传入日期进行转化
    setCalendar();
    getContent();
    $('#calendar').css({height: '20.6vh'});//背景图层
    $('.calendar').css({height: '13vh'});
    $('.cal-details').css({top: '13vh'});
    $('.details-title').css({top: '13vh'});
    load_team();

}

function load_team() {
    var get_url = tk_apiurl + "contacteam/findone";
    var team = {
        id: group_id
    };
    var data = {
        userId: user_id,
        token: token,
        data: JSON.stringify(team)
    };
    console.log(data);
    $.ajax({
        async: true,
        crossDomain: true,
        url: get_url,
        type: "POST",
        data: data,
        jsonpCallback: "jsoncallback",
        dataType: "jsonp",
        success: function (d) {
            console.log(d);
            var data = data_analysis(d);
            var data1 = data.result;
            if (data.statusCode == 202) {
                //-------------------------------------------
                $('.token_iframe').show();
            } else {
                var team_name = data1.teamName;
                $('.details-title').append("<span>" + team_name + "</span>");
            }
        }


    });
}

/*
 * 初始化时间
 */
function initTime() {
    var nowtime = new Date();
    var selectYear = nowtime.getYear() + 1900;//当前选择年
    var selectMonth = nowtime.getMonth();//当前选择月
    var selectDay = nowtime.getDate();//当前选择日
    $("#selectYear").val(selectYear);
    $("#selectMonth").val(selectMonth);
    $("#selectDay").val(selectDay);
    $("#pcalyear").html(selectYear + "年");//改变显示年
    today = selectDay;
    month = selectMonth;
    year = selectYear;
    setDisDate();//改变显示日期
    var hidyear = selectYear;
    selectMonth += 1;
    //初始化月份列表，以及月份对应的年
    for (var i = 0; i < 7; i++) {
        if (selectMonth - (3 - i) > 12) {
            $("#calmonthli li").eq(i).html(selectMonth - (3 - i + 12) + "月");
            $("#hidyear" + i).val(hidyear + 1);
        }
        else if (selectMonth - (3 - i) <= 0) {
            $("#calmonthli li").eq(i).html(selectMonth - (3 - i - 12) + "月");
            $("#hidyear" + i).val(hidyear - 1);
        }
        else {
            $("#calmonthli li").eq(i).html(selectMonth - (3 - i) + "月");
            $("#hidyear" + i).val(hidyear);
        }
    }
}
function turn_day() {
    console.log("turnDay:" + turnDay);
    if (turnDay != null) {
        var nowtime = new Date(Date.parse(turnDay));
        var selectYear = nowtime.getYear() + 1900;//当前选择年
        var selectMonth = nowtime.getMonth();//当前选择月
        var selectDay = nowtime.getDate();//当前选择日
        $("#selectYear").val(selectYear);
        $("#selectMonth").val(selectMonth);
        $("#selectDay").val(selectDay);
        $("#pcalyear").html(selectYear + "年");//改变显示年
        setDisDate();//改变显示日期
        var hidyear = selectYear;
        selectMonth += 1;
        //初始化月份列表，以及月份对应的年
        for (var i = 0; i < 7; i++) {
            if (selectMonth - (3 - i) > 12) {
                $("#calmonthli li").eq(i).html(selectMonth - (3 - i + 12) + "月");
                $("#hidyear" + i).val(hidyear + 1);
            }
            else if (selectMonth - (3 - i) <= 0) {
                $("#calmonthli li").eq(i).html(selectMonth - (3 - i - 12) + "月");
                $("#hidyear" + i).val(hidyear - 1);
            }
            else {
                $("#calmonthli li").eq(i).html(selectMonth - (3 - i) + "月");
                $("#hidyear" + i).val(hidyear);
            }
        }
    }
}

/*
 * 选择月的日历
 */
function setCalendar() {
    clearCalendar();

    var selectYear = $("#selectYear").val();
    var selectMonth = $("#selectMonth").val();
    var selectDay = $("#selectDay").val();
    var dmonth = selectMonth * 1 + 1;//获取当月最后一天所用月份（下个月的第0天）
    var dayNum = new Date(selectYear, dmonth, 0);//获取当月的最后一天
    var lastDayWeek = dayNum.getDay();
    dayNum = dayNum.getDate();
    var selectMonthDay = new Date(selectYear, selectMonth, 1);//选择月份的第一天
    var firstDayWeek = selectMonthDay.getDay();//获取第一天的星期

    if (firstDayWeek > 0) {
        for (var i = firstDayWeek - 1, j = 0; i >= 0; i--, j--) {
            var preNum = new Date(selectYear, selectMonth, j);
            if (i == 0) {
                start_time = new Date(Date.parse(preNum)).getTime();
            }
            preNum = preNum.getDate();
            $(".week-day-b li").eq(i).html("<span class='preMoth'>" + preNum + "</span>");//填写上月日期
        }

    } else if (firstDayWeek == 0) {

        for (var i = 6, j = 0; i >= 0; i--, j--) {
            var preNum = new Date(selectYear, selectMonth, j);
            if (i == 0) {
                start_time = new Date(Date.parse(preNum)).getTime();
            }
            preNum = preNum.getDate();
            $(".week-day-b li").eq(i).html("<span class='preMoth'>" + preNum + "</span>");//填写上月日期
        }
        //用完第一行，加一行
        for (var k = 0; k < 7; k++) {
            $("#caldayli").append("<li></li>");
        }
        firstDayWeek = 7;
    }
    if (lastDayWeek == 6) {
        lastDayWeek = -1;
    }
    for (var i = firstDayWeek, j = 1; i < $(".week-day-b li").length && j <= dayNum + (6 - lastDayWeek); i++, j++) {
        if (j > dayNum) {
            $(".week-day-b li").eq(i).html("<span  class='nextMoth'>" + (j - dayNum) + "</span>");//填写日期
        } else {
            $(".week-day-b li").eq(i).html("<span class='thisMoth'>" + j + "</span>");//填写日期

        }
        if (j == dayNum + (6 - lastDayWeek)) {
            var gmt = new Date(selectYear, selectMonth, j);
            end_time = new Date(Date.parse(gmt)).getTime();
        }
        if (j == today && selectMonth == month && selectYear == year)
            $(".week-day-b li").eq(i).addClass("today");
        if (j == selectDay)
            $(".week-day-b li").eq(i).addClass("duty-cur");
        if (i == $(".week-day-b li").length - 1 && j != dayNum + (6 - lastDayWeek)) {//如果日历格子不够再画一行
            for (var k = 0; k < 7; k++) {
                $("#caldayli").append("<li></li>");
            }
        }
    }
    //只显示当周
    var today_id = "";
    $(".week-day-b li").each(function (index) {
        if ($(this).attr("class") == "today duty-cur" || $(this).attr("class") == "duty-cur") {
            today_id = index;
        }
    });
    if (today_id != "") {
        var min = today_id - (today_id % 7);
        var max = min + 7;
        $(".week-day-b li").each(function (index) {
            if (index >= min && index < max) {
                $(this).css("display", "inline-block");
            } else {
                $(this).css("display", "none");
            }
        });
    }

    var url = apiurl + "/calendar";
    var data = {
        start_time: start_time,
        end_time: end_time,
        user_id: user_id,
        group_id: group_id,
        roleType: role
    };
    $.ajax({
        beforeSend: function () {
            $(".loading").show();
            console.log(start_time + "---" + end_time);
        },
        url: url,
        type: "GET",
        data: data,
        success: function (d) {
            $(".loading").hide();
            console.log(d);
            if (d.code == 1) {
                if (d.msg == "202") {
                    //-----------------------------------------------
                    $('.token_iframe').show();
                }
            } else {
                var data = JSON.parse(d).data;
                if (data == "" || data == null) {
                } else {
                    var calendar = data.calendar.split(";");
                    console.log(calendar);
                    //根据条件添加圆点任务标记
                    if (calendar.length == $(".week-day-b li").length) {
                        for (i = 0; i < $(".week-day-b li").length; i++) {
                            if (calendar[i] == 1) {
                                if ($(".week-day-b li").eq(i).find('span').attr("class") == 'thisMoth') {
                                    $(".week-day-b li").eq(i).append("<div class='duty-sign'><img src='img/point_white.png' class='white-round'/></div>")
                                } else {
                                    $(".week-day-b li").eq(i).append("<div class='duty-sign'><img src='img/point_grey.png' class='grey-round'/></div>")
                                }
                            } else {
                                $(".week-day-b li").eq(i).append("<div class='duty-sign'></div>")
                            }
                        }
                    }
                }
            }

        },
    });
    // //当天有任务要显示
    // var today_content = $('.today')[0];
    // getContent();
    //绑定日历li点击事件
    $('.thisMoth').click(function () {
        setDayStyle(this);
        getContent();
    });
    $('.preMoth').click(function () {
        setDayStyle(this);
        setLastMonth();
        down();
        getContent();

    });
    $('.nextMoth').click(function () {
        setDayStyle(this);
        setNextMonth();
        down();
        getContent();

    });

}

//点击approval_item头像进行跳转
var id_toInfo;
id_toInfo = document.createElement('iframe');
id_toInfo.style.display = 'none';
document.documentElement.appendChild(id_toInfo);
$(document).on('click', '.approval_item', function () {
    id_toInfo.src = "/usercard?id=" + $(this).attr("id").replace(/approval/, "");
});
//点击dailycord_item头像进行跳转
$(document).on('click', '.dailycord_item', function () {
    id_toInfo.src = "/usercard?id=" + $(this).attr("id").replace(/dailycord/, "");
});
/*
 * 清空日历
 */
function clearCalendar() {
    $("#caldayli").html("");
    for (var k = 0; k < 7; k++) {
        $("#caldayli").append("<li></li>");
    }
}

//获取当天的具体情况（审批、日志和任务）
function getContent() {
    // if ($(dom).parent().find("white-round") != null) {
    console.log($("#disDate").text());
    day = new Date(Date.parse($("#disDate").text())).getTime();
    var url = apiurl + "/calendar/list";
    var data = {
        day: day,
        user_id: user_id,
        group_id: group_id,
        token: token,
        roleType: role

    };
    $.ajax({
        beforeSend: function () {
            $(".loading").show();
            console.log("day---" + day);
        },
        url: url,
        type: "GET",
        data: data,
        success: function (d) {
            $(".loading").hide();
            console.log(d);
            if (d.code == 1) {
                if (d.msg == "202") {
                    //-----------------------------------------------
                    $('.token_iframe').show();
                }
            } else {

                var data = JSON.parse(d).data;
                console.log(data);
                if (data == null || data == "" || data.length <= 0) {
                    console.log("kong");
                    $(".details-none").show();
                    $(".details-list").hide();
                } else {
                    var approvals = data.approvals;
                    var dailycord = data.dailycord;
                    var projecttask = data.projecttask;
                    var userInfos = data.userInfos;
                    if (approvals == null && dailycord == null && projecttask == null) {
                        console.log("kong");
                        $(".details-none").show();
                        $(".details-list").hide();
                    } else {
                        $(".details-none").hide();
                        $(".details-list").show();
                        $(".duty-content").html("");
                    }
                    //审核
                    if (approvals == null || approvals == "") {
                        $("#approvals").hide();
                    }
                    else {
                        $("#approvals").show();

                        for (var i = 0; i < approvals.length; i++) {
                            var approvals_content = "<div class='duty-item'><div class='item-title'><span class='duty-reason'>" +
                                approvals[i].approval_temp_name + "</span><span>:</span><span class='duty-num'>" +
                                approvals[i].approvals.length + "</span><span>人</span></div><ul class='item-numb' id='approval_numb"+i+"'></ul></div>";
                            $('#approvals_content').append(approvals_content);
                            var approvals_list = approvals[i].approvals;
                            for (var k = 0; k < approvals_list.length; k++) {
                                var item_id = approvals_list[k].user_id;
                                var approval_name,approval_img_name, approval_avatar;
                                for (var j = 0; j < userInfos.length; j++) {
                                    if (item_id == userInfos[j].id) {
                                        approval_name = userInfos[j].name;
                                        approval_img_name=approval_name.substring(approval_name.length-2,approval_name.length);
                                        approval_avatar = userInfos[j].avatar;
                                        var approval_qyxBindId = userInfos[j].qyxBindId;


                                        var bgColor = avatar_getColor(approval_qyxBindId);
                                        var avatar_component = "<div class='item-icon' style='background: " + bgColor + "'>" + approval_img_name + "</div>";
                                        if (approval_avatar.length > 0) {
                                            approval_avatar = avatar_getUrl(user_id, token, approval_avatar);
                                            avatar_component += "<img src='" + approval_avatar + "' class='item-icon' hidden>";
                                        }


                                         //item_numb = "";

                                        //if (approval_avatar == "") {
                                        var item_numb = "<li>" +
                                                            "<div class='approval_item' id='approval" + approval_qyxBindId + "'>" +
                                                                "<div>" +
                                                                    avatar_component +
                                                                "</div>" +
                                                                "<div class='item-name'>" + approval_name + "</div>" +
                                                            "</div>" +
                                                        "</li>";

                                        //} else {
                                        //    approval_avatar = avatar_getUrl(user_id, token, approval_avatar);
                                        //    item_numb = "<li>" +
                                        //                    "<div class='approval_item' id='approval" +  approval_qyxBindId + "'>" +
                                        //                        "<div>" +
                                        //                            "<img src='" + approval_avatar + "' class='item-icon'>" +
                                        //                        "</div>" +
                                        //                        "<div class='item-name'>" + approval_name + "</div>" +
                                        //                    "</div>" +
                                        //                "</li>";
                                        //}
                                        $('#approval_numb'+i).append(item_numb);
                                    }
                                }



                            }
                            showAvatar(".item-icon");

                        }


                    }

                    //日志
                    if (dailycord == null || dailycord == "") {
                        $("#dailycord").hide();
                    }
                    else {
                        $("#dailycord").show();
                        var dailycord_content = "<div class='duty-item'><div class='item-title'><span class='duty-reason'>已提交</span><span>:</span><span class='duty-num'>" + dailycord.length + "</span><span>人</span></div><ul class='item-numb' id='dailycord_numb'></ul></div>";
                        $('#dailycord_content').append(dailycord_content);
                        for (var i = 0; i < dailycord.length; i++) {
                            var item_id = dailycord[i].user_id;
                            var dailycord_name,dailycord_img_name, dailycord_avatar = "";
                            for (var j = 0; j < userInfos.length; j++) {
                                if (item_id == userInfos[j].id) {
                                    dailycord_name = userInfos[j].name;
                                    dailycord_img_name = dailycord_name.substring(dailycord_name.length-2,dailycord_name.length);
                                    dailycord_avatar = userInfos[j].avatar;
                                    var dailycord_qyxBindId = userInfos[j].qyxBindId;

                                    var bgColor = avatar_getColor(dailycord_qyxBindId);
                                    var avatar_component = "<div class='item-icon' style='background: " + bgColor + "'>" +  dailycord_img_name + "</div>";

                                    if (dailycord_avatar.length > 0) {
                                        dailycord_avatar = avatar_getUrl(user_id, token, dailycord_avatar);
                                        avatar_component += "<img src='" + dailycord_avatar + "' class='item-icon' hidden>";
                                    }


                                    //item_numb = "";

                                    //if (approval_avatar == "") {



                                    //var item_numb = "";
                                    //if (dailycord_avatar == "") {
                                    var item_numb = "<li><div class='dailycord_item' id='dailycord" +
                                            dailycord_qyxBindId + "'><div>"+ avatar_component +"</div><div class='item-name'>" +
                                            dailycord_name + "</div></div></li>";

                                    //} else {
                                    //    dailycord_avatar = avatar_getUrl(user_id, token, dailycord_avatar);
                                    //    item_numb = "<li><div class='dailycord_item' id='dailycord" +
                                    //        dailycord_qyxBindId + "'><div><img src='" +
                                    //        dailycord_avatar + "' class='item-icon'></div><div class='item-name'>" +
                                    //        dailycord_name + "</div></div></li>";
                                    //}
                                    $('#dailycord_numb').append(item_numb);
                                }
                            }
                        }
                        showAvatar(".item-icon");
                    }
                    //任务
                    if (projecttask == null || projecttask == "") {
                        $("#projecttask").hide();
                    }
                    else {
                        $("#projecttask").show();
                        for (var i = 0; i < projecttask.length; i++) {
                            var duty_endtime = new Date(projecttask[i].complete_timestamp);
                            initDate(duty_endtime);
                            var projecttask_content = "<div class='duty-item'><div class='item-title'><span class='duty-name'>" + projecttask[i].project_task_name + "</span></div><div class='duty_opts'><img src='img/duty_endtime.png' class='duty_img'/><div class='duty_endtime'>" + mon_day_cn + "</div><img src='img/duty_belong.png' class='duty_img'/><div class='duty_belong'>" + projecttask[i].project_name + "</div></div>";

                            $('#projecttask_content').append(projecttask_content);

                        }
                    }
                }
            }
        },
        error: function (d) {
            console.log(d);
        }
    });
    // }else {
    //     $(".details-none").show();
    //     $(".details-list").hide();
    // }
}

/*
 * 选择日期
 */
function setDayStyle(dom) {
    $(".week-day-b li").removeClass("duty-cur");
    $(dom).parent().addClass("duty-cur");
    var v = dom.innerHTML;//获取点击结点日期
    $("#selectDay").val(v);//改变当前选择日期
    setDisDate();//改变显示日期

}

/*
 * 选择月份
 */
function setMonthStyle(dom) {
    $(".calendar-months li").removeClass("months-cur");
    $(dom).addClass("months-cur");
    $("#selectMonIndex").val($(dom).index());//设置选中月下标
    var v = $(dom).html();//获取选择月份
    if (v.length == 3)
        v = v.substring(0, 2);
    else
        v = v.substring(0, 1);
    v = v - 1;
    $("#selectMonth").val(v);//改变选择月
    var index = $(dom).index();//获取月份li对应索引
    var selectYear = $("#hidyear" + index).val();//获得选择年
    $("#selectYear").val(selectYear);//改变选择年
    $("#pcalyear").html(selectYear + "年");//改变显示年
    setDisDate();//变更显示日期
    setCalendar();//变更日历


}

/*
 * 设置下一页月份;
 */
function setNextMonth() {
    //设置下一页月份，点一下翻半年
    // for (var i = 0; i < 7; i++) {
    //     var m = $("#calmonthli li").eq(i).html();
    //     m = m.substring(0, m.length - 1);
    //     if ((m * 1 + 6) > 12) {//设置对应月份的年份
    //         var hidyear = $("#hidyear" + i).val();
    //         $("#hidyear" + i).val(hidyear * 1 + 1);
    //     }
    //     if ((m * 1 + 6) == 12)
    //         $("#calmonthli li").eq(i).html(12 + "月");
    //     else
    //         $("#calmonthli li").eq(i).html((m * 1 + 6) % 12 + "月");//设置当月li
    // }
    for (var i = 0; i < 7; i++) {
        var m = $("#calmonthli li").eq(i).html();
        m = m.substring(0, m.length - 1);
        if ((m * 1 + 1) > 12) {
            var hidyear = $("#hidyear" + i).val();
            $("#hidyear" + i).val(hidyear * 1 + 1);
        }
        if ((m * 1 + 1) == 12) {
            $("#calmonthli li").eq(i).html(12 + "月");
        }
        else {
            $("#calmonthli li").eq(i).html((m * 1 + 1) % 12 + "月");
        }//设置当月li
    }
    //改变选择月
    var selectMonth = $("#selectMonth").val();
    $("#selectMonth").val((selectMonth * 1 + 1) % 12);
    //改变选择年
    var index = $("#selectMonIndex").val();//获取选中月下标
    var syear = $("#hidyear" + index).val();//获取选中月对应年
    $("#selectYear").val(syear);//设置选中年
    $("#pcalyear").html(syear + "年");//改变显示年
    //改变日历
    setCalendar();
    setDisDate();//改变显示日期
}

/*
 * 设置上一页月份
 */
function setLastMonth() {
    for (var i = 0; i < 7; i++) {
        var m = $("#calmonthli li").eq(i).html();
        m = m.substring(0, m.length - 1);
        if ((m * 1 - 1) <= 0) {//设置对应月份的年份
            var hidyear = $("#hidyear" + i).val();
            $("#hidyear" + i).val(hidyear * 1 - 1);
        }
        if ((m * 1 - 1 + 12) == 12) {
            $("#calmonthli li").eq(i).html(12 + "月");
        }
        else {
            $("#calmonthli li").eq(i).html((m * 1 - 1 + 12) % 12 + "月");
        }//设置当月li
    }
    //改变选择月
    var selectMonth = $("#selectMonth").val();
    $("#selectMonth").val((selectMonth * 1 - 1 + 12) % 12);
    //改变选择年
    var index = $("#selectMonIndex").val();//获取选中月下标
    var syear = $("#hidyear" + index).val();//获取选中月对应年
    $("#selectYear").val(syear);//设置选中年
    $("#pcalyear").html(syear + "年");//改变显示年
    //改变日历
    setCalendar();
    setDisDate();//改变显示日期
}

/*
 * 设置显示日期
 */
function setDisDate() {
    var selectYear = $("#selectYear").val();//获取选中年月日
    var selectMonth = $("#selectMonth").val();
    var selectDay = $("#selectDay").val();
    var now = new Date(selectYear, selectMonth, selectDay);
    var selectWeek = now.getDay();//获取选中天数日期
    selectWeek = getweek(selectWeek);
    //设置年月日
    // $("#disDate").html(selectYear + "年 " + (selectMonth * 1 + 1) + "月 " + selectDay + "日  星期" + selectWeek);
    $("#disDate").html(selectYear + ". " + (selectMonth * 1 + 1) + ". " + selectDay);
}

/*
 * 获得星期
 */
function getweek(day) {
    var week = "";
    switch (day) {
        case 0:
            week = "日";
            break;
        case 1:
            week = "一";
            break;
        case 2:
            week = "二";
            break;
        case 3:
            week = "三";
            break;
        case 4:
            week = "四";
            break;
        case 5:
            week = "五";
            break;
        case 6:
            week = "六";
            break;
    }
    return week;
}

$(document).on('click', '#href_approval', function () {
    var skip_day = $("#disDate").text();
    window.location.href = '../approval/html/index.html?turnDay=' + skip_day;
});
$(document).on('click', '#href_log', function () {
    var skip_day = $("#disDate").text();
    window.location.href = '../log/logHtml/index.html?turnDay=' + skip_day;
});
$(document).on('click', '#href_task', function () {
    var skip_day = $("#disDate").text();
    window.location.href = '../task/index.html?turnDay=' + skip_day;
});

//滑动相册
function left() {
    setNextMonth();
    down();
    getContent();

}

function right() {
    setLastMonth();
    down();
    getContent();
}

function up() {
    var today_id = "";
    $(".week-day-b li").each(function (index) {
        if ($(this).attr("class") == "today duty-cur" || $(this).attr("class") == "duty-cur") {
            today_id = index;
        }
    });
    if (today_id == "") {
        //不是当天所在月

        //上移至top：10vh
        $('#calendar').animate({height: '20.6vh'});//背景图层
        $('.calendar').animate({height: '13vh'});
        $('.cal-details').animate({top: '13vh'});
        $('.details-title').animate({top: '13vh'});
    } else {
        //上移至top：10vh
        $('#calendar').animate({height: '20.6vh'});//背景图层
        $('.calendar').animate({height: '13vh'});
        $('.cal-details').animate({top: '13vh'});
        $('.details-title').animate({top: '13vh'});
        setTimeout(function () {
                //做默认显示
                var min = today_id - (today_id % 7);
                var max = min + 7;
                $(".week-day-b li").each(function (index) {
                    if (index >= min && index < max) {
                        $(this).css("display", "inline-block");
                    } else {
                        $(this).css("display", "none");
                    }
                });
            }, 400
        );


    }

}

function showAvatar(classname){
    $(classname).one("load",function(){
        $(this).show();
        $(this).prev().hide();
    });
}

function down() {
    var today_id = "";
    $(".week-day-b li").each(function (index) {
        if ($(this).attr("class") == "today duty-cur" || $(this).attr("class") == "duty-cur") {
            today_id = index;
        }
    });
    if (today_id == "") {
        //不是当天所在月
    } else {
        $(".week-day-b li").each(function (index) {
            $(this).css("display", "inline-block");
        });

    }
    //下移距离ch
    var ch = $('.calendar-day').height();
    var bgh = $('.header').height() + ch;//背景图层
    $('#calendar').animate({height: bgh});//背景图层
    $('.calendar').animate({height: ch});
    $('.details-title').animate({top: ch});
    $('.cal-details').animate({top: ch});
}